<?php include '_init_.php';?>
<?php include 'page_header.php';?>
<div id="main"><!-- start #main //-->
<div id="tita"> <!-- start #tita //-->
<?php define('ORDER_NAVIGATOR_ITEM','金額查詢');?>
<?php include 'navigator_order_search.php';?>
<?php define('ORDER_MENU_CURRENT_ITEM','金額');?>
<?php include 'order_search_menu.php';?>
<?php

$act = isset($_REQUEST['act'])?$_REQUEST['act']:'';
$condition = isset($_REQUEST['condition'])?$_REQUEST['condition']:'';
if($act == 'search')
{
	$condition = "";
	if(strlen($_REQUEST['start']) > 0)
	{
		$condition .= sprintf("TO_DAYS(`created`) >= TO_DAYS('%s') and ",date('Y-m-d',strtotime($_REQUEST['start'])));
	}
	if(strlen($_REQUEST['end']) > 0)
	{
		$condition .= sprintf("TO_DAYS(`created`) <= TO_DAYS('%s') and ",date('Y-m-d',strtotime($_REQUEST['end'])));
	}
	if(strlen($_REQUEST['amount_from']) > 0)
	{
		$condition .= sprintf("`total_price` >= %d and ",$_REQUEST['amount_from']);
	}
	if(strlen($_REQUEST['amount_to']) > 0)
	{
		$condition .= sprintf("`total_price` <= %d and ",$_REQUEST['amount_to']);
	}
	if(strlen($condition) > 0)
	{
		$condition = substr($condition,0,strlen($condition) - 4);
	}
	/*
	$link = sprintf("search_list.php?condition=%s",urlencode($condition));
	header('Location:'.$link);
	exit();*/
}
?>
<form action="searchf.php">
<input type="hidden" name="act" value="search"/>
<div id="mainf" class="clearfix"><!-- start #maine //-->

<div class="mainf-3">
<ul>
      <li class="maine-1c">
       日期<input type="text" class="maine-keyink datepicker" name="start" value="<?php echo isset($_REQUEST['start'])?$_REQUEST['start']:'';?>">到<input type="text" class="maine-keyink datepicker" name="end" value="<?php echo isset($_REQUEST['end'])?$_REQUEST['end']:'';?>"></li>
       </ul>
 </div>
<div class="mainf-3">
<ul>
      <li class="maine-1c">
       金額<input type="text" class="maine-keyink _validate_form_float" name="amount_from" value="<?php echo isset($_REQUEST['amount_from'])?$_REQUEST['amount_from']:'';?>">到<input type="text" class="maine-keyink _validate_form_float" name="amount_to" value="<?php echo isset($_REQUEST['amount_to'])?$_REQUEST['amount_from']:'';?>"></li>
       </ul>
   
     </div>
<div class="mainf-4">
<ul>
     <li class="maina-1d"><a href="#" onclick="document.forms[0].submit();return false;"><img src="images/search-btn.gif" width="81" height="29" /></a></li>
   </ul>
     </div>
     </div><!-- end #maine //-->
     </form>
          <?php 
     if(isset($_REQUEST['act']) || isset($_REQUEST['p']))
     {
     	 include('search_list.php');
     }
     ?>
</div><!-- end #main //-->

</div><!-- end #all //-->

</body>
</html>